﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Web.Media.SmoothStreaming;
using System.Threading;
using LiveStream.Caching;
using System.Windows.Threading;

namespace LiveStream
{
    public partial class PlaybackPanel : UserControl
    {
		//IsolatedStorageSmoothStreamingCache _streamingCache = new IsolatedStorageSmoothStreamingCache();

		public PlaybackPanel()
		{
			InitializeComponent();
			//this.Player.SmoothStreamingCache = _streamingCache;
		}

		private void InitializeControlsWindow()
		{
			Window controlsWindow = new Window();
			controlsWindow.WindowStyle = WindowStyle.SingleBorderWindow;
			controlsWindow.Title = "Live Stream Controls";

			Window mainWindow = Window.GetWindow(this);

			var playbackControls = new PlaybackControls(this.Player);
			controlsWindow.Content = playbackControls;
			controlsWindow.Width = 1350;
			controlsWindow.Height = 250;
			controlsWindow.Top = mainWindow.Top + mainWindow.Height - controlsWindow.Height;
			controlsWindow.Left = mainWindow.Left + (mainWindow.Width - controlsWindow.Width) / 2;

			controlsWindow.Closing += new EventHandler<System.ComponentModel.ClosingEventArgs>(
					(sender, e) => mainWindow.Close()
				);

			controlsWindow.Visibility = Visibility.Visible;
		}

		private void UserControl_Loaded(object sender, RoutedEventArgs e)
		{
			InitializeControlsWindow();
		}
    }
}
